Support !degree & !randians yaml prefixes#7
Open
JafarAbdi wants to merge 3 commits intoPickNikRobotics:mainfrom
Open
Support !degree & !randians yaml prefixes#7JafarAbdi wants to merge 3 commits intoPickNikRobotics:mainfrom
JafarAbdi wants to merge 3 commits intoPickNikRobotics:mainfrom
Conversation
MarqRazz
reviewed
Feb 20, 2023
MarqRazz
left a comment
There was a problem hiding this comment.
@JafarAbdi the changes look simple enough but do we have a easy way to test this? I though I had a quick way but I don't have a moveit_config that uses the param_builder.
The ur_moveit_launch.py does not use it.
Maybe we could add it to the moveit_resources_panda_robot demo.launch.py so we can verify this is working properly.
sea-bass
reviewed
Feb 27, 2023
Comment on lines
+87
to
+95
| try: | ||
| yaml.SafeLoader.add_constructor("!radians", construct_angle_radians) | ||
| yaml.SafeLoader.add_constructor("!degrees", construct_angle_degrees) | ||
| except Exception: | ||
| raise Exception("yaml support not available; install python-yaml") | ||
|
|
||
| try: | ||
| with open(file_path, "r") as file: | ||
| return yaml.load(file, Loader=yaml.FullLoader) | ||
| except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available | ||
| return yaml.safe_load(file) |
There was a problem hiding this comment.
Based on this resource and some limitation I found when integrating this in Studio, I have a suggestion.
First, make a function like this which we can use standalone:
def get_yaml_loader():
"""Gets a YAML loader that additionally supports custom constructors."""
loader = yaml.SafeLoader
loader.add_constructor("!radians", construct_angle_radians)
loader.add_constructor("!degrees", construct_angle_degrees)
return loader
Then, in your implementation, you can do:
def load_yaml(file_path: Path, loader=get_yaml_loader()):
...
return yaml.load(file, Loader=loader)
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
Contributor
Author
|
Replaced with #9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This's makes it so it's possible to have '!degrees' and '!radians' in the yaml config files (UR's joint limits for an example)